home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form Form1
- BorderStyle = 3 'Fixed Dialog
- Caption = "Base64"
- ClientHeight = 780
- ClientLeft = 45
- ClientTop = 330
- ClientWidth = 2040
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 780
- ScaleWidth = 2040
- ShowInTaskbar = 0 'False
- StartUpPosition = 3 'Windows Default
- Begin VB.CommandButton Command1
- Caption = "Test Speed"
- Height = 675
- Left = 60
- TabIndex = 0
- Top = 60
- Width = 1935
- End
- Attribute VB_Name = "Form1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Dim Base64 As New Encoding
- Private Declare Function GetTickCount Lib "kernel32" () As Long
- Private Sub Command1_Click()
- 'COMPILE THIS TO AN NATIVE-EXE FOR BEST PERFORMANCE
- 'THE VB IDE IS MORE THAN 10 TIMES SLOWER THAN
- 'A COMPILED EXECUTABLE
- Dim TempArray() As Byte
- Dim Encoded() As Byte
- Dim Elapsed As Single
- Dim EncodingRate As Single
- Dim Message As String
- Base64.Str2ByteArray String(1000000, "A"), TempArray 'encode a 1 megabyte string full of A's
- Elapsed = GetTickCount
- Base64.EncodeB64 TempArray, Encoded
- 'Encoded() now contains the encoded byte array
- 'to convert it to a string use:
- 'a = StrConv(Encoded, vbUnicode)
- 'a will now have the decoded string
- 'IMPORTANT NOTE: If you plan to use this in a
- 'email program, you should use the Span() function
- 'so the encoded string will have a maximum of 74 chars
- 'per line.
- 'Base64.Span 74, Encoded, TempArray
- ' - Encoded is the encoded byte array
- ' - TempArray is an array that will contain the result
- 'This function is not fully beta-tested, so be careful
- 'with it
- EncodingRate = GetTickCount - Elapsed
- EncodingRate = Round(1000 / EncodingRate, 2)
- Message = "On your current system you will get " & EncodingRate & "Mb/sec at encoding." & vbCrLf
- Elapsed = GetTickCount
- 'If Encoded() was previously Spanned with base64.span()
- 'you should unspan it like so:
- 'Base64.Unspan Encoded, TempArray
- 'TempArray() will now contain an unspanned string,
- 'ready for decoding
- 'NOTE:
- 'This function is not fully beta-tested, so be careful
- 'with it
- Base64.DecodeB64 Encoded, TempArray
- 'TempArray() now contains the decoded byte array
- 'to convert it to a string use:
- 'a = StrConv(TempArray, vbUnicode)
- 'a will now have the decoded string
- EncodingRate = GetTickCount - Elapsed
- EncodingRate = Round(1000 / EncodingRate, 2)
- Message = Message & "On your current system you will get " & EncodingRate & "Mb/sec at decoding."
- MsgBox Message, vbInformation
- End Sub
- Private Sub Form_Load()
- Base64.Class_Initialize
- End Sub
-